#ifndef __LOG_H__
#define __LOG_H__

#include <stdio.h>
#include <stdint.h>
#include "wrap_stdio.h"


#define LOG_DEBUG_PRINTF    		1
	
#define LOG_EMERG               0
#define LOG_ERROR               (LOG_EMERG + 1)
#define LOG_WARN                (LOG_EMERG + 2)
#define LOG_INFO                (LOG_EMERG + 3)
#define LOG_DEBUG               (LOG_EMERG + 4)
#define LOG_TRACE               (LOG_EMERG + 5)
#define LOG_CTRL                LOG_INFO     //By modifying this value, control the different levels of log printing


int log_stdio_write(const char *buf, size_t size);

void log_init(void);
void log_deint(void);

void hexdump(uint8_t level, const char *info, void *buff, uint32_t count);

#define log_printf(...)     __wrap_sprintf((stdio_write_fn)log_stdio_write, __VA_ARGS__)
#define log_raw_data_flush(data, len) __wrap_stdio_raw_data_flush((const char *)data, (stdio_write_fn)log_stdio_write, (size_t)len)

#if (LOG_DEBUG_PRINTF==1)
	
#define LOG(level, ...)                  \
			do{                              \
				if(level <= LOG_CTRL){   \
					log_printf(__VA_ARGS__); \
					log_printf("\r\n");		\
				}                            \
			}while(0)
				
#else
	LOG(level, ...)    
#endif




#endif


